<?php

namespace common\behavior\CommonMessagePushing;

use Webman\Stomp\Client;

/**
 * 任务启用行为 消息通知
 */
class TaskReopenBehavior
{
    /**
     * @param $params
     * @return void
     */
    public function run($params)
    {
        if ($params['operate'] != 'enable') {
            return;
        }
        $data = [
            'source_user_id' => $params['operate'] ?? \request()->getUserId(),
            'time' => $params['operate_at'] ?? time(),
            'source_id' => $params['task_id'],
            'source_module_code' => 'task',
            'category' => 'task_reopen',
            'receiver' => $taskAssignInfo['receiver'] ?? [],
            'receiver_cc' => $taskAssignInfo['receiver_cc'] ?? [],
        ];
        try {
            trace("common task reopen push behavior" . request()->getUnionUserId(), 'DEBUG');
            Client::send('common_message_pushing', build_queue_data_with_xu($data));
        } catch (\Throwable $e) {
            trace(format_exception_info($e), 'ERR');
        }
        return;
    }
}
